package com.technology.education.ui.market

import android.os.Bundle
import com.technology.education.databinding.ActivityMainMarketBinding
import com.technology.education.ext.fragmentInStackSize
import com.technology.education.ext.getAppViewModel
import com.technology.education.ext.toast
import me.hgj.jetpackmvvm.base.activity.BaseVmDbActivity
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

/**
 *@author:create by BZY
 *Date: 2022/3/30 07
 */
class MainMarketActivity : BaseVmDbActivity<BaseViewModel, ActivityMainMarketBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        getAppViewModel().getInfo(true)
    }

    override fun showLoading(message: String) {
    }

    override fun dismissLoading() {
    }

    override fun createObserver() {
    }

    var currentTime: Long = 0
    override fun onBackPressed() {
        if (fragmentInStackSize() == 1) {
            ///这里做一个判断当前是否在主页面,如果在则提示退出操作
            if (System.currentTimeMillis() - currentTime >= 2 * 1000) {
                toast("再按一次退出应用")
                currentTime = System.currentTimeMillis()
            } else {
                finish()
            }
        } else {

            super.onBackPressed()
        }
    }
}